//
//  HACNodesComponentMultiMLine.m
//  HStockCharts
//
//  Created by Hotacool on 2018/11/15.
//

#import "HACNodesComponentMultiMLine.h"
#import "HACMultiMLineNode.h"

@implementation HACNodesComponentMultiMLine

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.orderSwitchTecNodeTypes = @[@(HACTecTypeVolume)];
    }
    return self;
}

- (void)initialNodes {
    self.contentScroll.scrollEnabled = NO;
    self.visualCount = 241*5;
    
    HACMLineNode *mline = [[HACMultiMLineNode alloc] initWithHostLayer:self.layer];
    mline.visualCount = 241*5;
    [self.nodeDic setObject:mline forKey:HACNodesComponentMainNodeKey];
}

- (void)setTecNodeTypes:(NSArray<NSNumber *> *)tecNodeTypes {
    [super setTecNodeTypes:tecNodeTypes];
    [self.tecBars enumerateObjectsUsingBlock:^(HACTecInfoBar * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        obj.titleButton.imageView.hidden = YES;
        obj.titleButton.userInteractionEnabled = NO;
    }];
}

- (void)setUpMarketTimeBarWithTimeArray:(NSArray*)timesArray {
    [self addSubview:self.marketTimeBar];
    timesArray = self.basicInfoData.timeArray;
    if (!timesArray || timesArray.count == 0) {
        return;
    }
    CGFloat width = self.marketTimeBar.frame.size.width / timesArray.count;
    for (int i = 0; i < timesArray.count; i++) {
        UILabel *label = [self.marketTimeBar viewWithTag:1000+i];
        if (!label) {
            label = [[UILabel alloc] init];
            label.tag = 1000+i;
            label.font = [UIFont systemFontOfSize:10];
            label.textColor = RGB_HEX(kAxisTextColor);
            label.textAlignment = NSTextAlignmentCenter;
            [self.marketTimeBar addSubview:label];
        }
        label.text = timesArray[i];
        label.frame = CGRectMake(i*width, 0, width, self.marketTimeBar.frame.size.height);
    }
}
@end
